package com.ssm.study.controller;

import com.ssm.study.entity.Game;
import com.ssm.study.entity.User;
import com.ssm.study.service.IGameService;
import com.ssm.study.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import java.util.List;

/**
 * Created by w on 2017/4/16.
 */

@Controller
@RequestMapping("/game")
public class GameController extends HttpServlet {

    @Resource
    IGameService gameService;


    @RequestMapping(value = "list", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gameList() {
        ModelAndView mav = new ModelAndView("gamelist");

        List<Game> gameList = gameService.getAllGames();

        mav.addObject("gameList", gameList );

        return mav;
    }

    @RequestMapping(value = "info", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gameInfo(int id) {
        ModelAndView mav = new ModelAndView("gameinfo");

      //  List<Game> gameList = gameService.getAllGames();

        mav.addObject("id", id );

        return mav;
    }

}
